package com.lizhijun.controller;

import com.lizhijun.pojo.Department;
import com.lizhijun.service.DepartmentService;
import com.lizhijun.utils.LayuiTransform;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
public class DepartmentController {
    @Autowired
    private DepartmentService departmentService;

    @RequestMapping("/findAllDepartment")
    @ResponseBody
    public LayuiTransform<Department> findAllDepartment(){
        List<Department> departmentList = departmentService.findAllDepartment();
        LayuiTransform<Department> layuiTransform = new LayuiTransform<>();
        layuiTransform.setData(departmentList);
        layuiTransform.setCode(0);
        layuiTransform.setCount(departmentList.size());
        layuiTransform.setMsg("success");
        return layuiTransform;
    }
}
